package com.zlc.proxy;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.View;

public class ViewChangeBgTool {
	
	private Context context;
	
	private List<ButtonResource> list;
	
	public ViewChangeBgTool(Context context) {
		this.context = context;
		this.list = new ArrayList<ViewChangeBgTool.ButtonResource>();
	}
	
	public void addButton(ViewChangeBgTool.ButtonResource but) {
		list.add(but);
	}
	
	public void changeButtonBg(View v) {
		for(int i = 0; i < list.size(); i ++) {
			ButtonResource br = list.get(i);
			if(br.view == v) {
				br.view.setSelected(true);
				br.view.setBackgroundResource(br.selected);
			} else {
				br.view.setSelected(false);
				br.view.setBackgroundResource(br.unSelected);
			}
		}
	}

	public static class ButtonResource {
		View view;
		int selected;
		int unSelected;
		
		public ButtonResource(View view, int selected, int unSelected) {
			this.view = view;
			this.selected = selected;
			this.unSelected = unSelected;
		}
	}
	
}
